$.validator.setDefaults({
    debug: false
});
$().ready(function() {
// 在键盘按下并释放及提交后验证提交表单
    $("#add-modal-form").validate({
        errorPlacement: function(error, element) {
            // Append error within linked label
            error.appendTo(element.parent());
        },
        errorElement: "p",
        rules: {
            name: "required",
            pwd: {
                required: true,
                minlength: 6
            },
            confirm_password: {
                required: true,
                minlength: 6,
                equalTo: "#pwd"
            },
            phone: {
                required: true,
                rangelength : [11,11]
            },
            address: "required",
            code: {
                required: true
            },
            pic: "required",
            price: {
                required: true,
                min: 0
            },
            number: {
                required: true,
                min: 0,
                digits: true
            },
            quantity: {
                required: true,
                min: 0,
                digits: true
            },
            purchasePrice: {
                required: true,
                min: 0
            },
            orderDate: {
                required: true
            },
            remark: "required"
        },
        messages: {
            name: "名称不能为空",
            pwd: {
                required: "密码不能为空",
                minlength: "长度不能小于6"
            },
            confirm_password: {
                required: "密码不能为空",
                minlength: "长度不能小于6",
                equalTo: "两次密码输入不一致"
            },
            phone: "号码格式错误",
            address: "地址不能为空",
            code: {
                required: "验证码不能为空"
            },
            pic: "图片不能为空",
            price: {
                required: "价格不能为空",
                min: "价格不能小于0"
            },
            number: {
                required: "库存不能为空",
                min: "库存不能小于0",
                digits: "库存必须是整数"
            },
            quantity: {
                required: "数量不能为空",
                min: "数量不能小于0",
                digits: "数量必须是整数"
            },
            purchasePrice: {
                required: "价格不能为空",
                min: "价格不能小于0"
            },
            orderDate: {
                required: "日期不能为空"
            },
            remark: "备注不能为空"
        }
    });
    $("#update-modal-form").validate({
        errorPlacement: function(error, element) {
            // Append error within linked label
            error.appendTo(element.parent());
        },
        errorElement: "p",
        rules: {
            name: "required",
            pwd: {
                required: true,
                minlength: 6
            },
            confirm_password: {
                required: true,
                minlength: 6,
                equalTo: "#pwd"
            },
            phone: {
                required: true,
                rangelength : [11,11]
            },
            address: "required",
            pic: "required",
            price: {
                required: true,
                min: 0
            },
            number: {
                required: true,
                min: 0,
                digits: true
            },
            quantity: {
                required: true,
                min: 0,
                digits: true
            },
            purchasePrice: {
                required: true,
                min: 0
            },
            orderDate: {
                required: true,
                date: true
            },
            remark: "required"
        },
        messages: {
            name: "名称不能为空",
            pwd: {
                required: "密码不能为空",
                minlength: "长度不能小于6"
            },
            confirm_password: {
                required: "密码不能为空",
                minlength: "长度不能小于6",
                equalTo: "两次密码输入不一致"
            },
            phone: "号码格式错误",
            address: "地址不能为空",
            pic: "图片不能为空",
            price: {
                required: "价格不能为空",
                min: "价格不能小于0"
            },
            number: {
                required: "库存不能为空",
                min: "库存不能小于0",
                digits: "库存必须是整数"
            },
            quantity: {
                required: "数量不能为空",
                min: "数量不能小于0",
                digits: "数量必须是整数"
            },
            purchasePrice: {
                required: "价格不能为空",
                min: "价格不能小于0"
            },
            orderDate: {
                required: "日期不能为空",
                date: "日期格式错误"
            },
            remark: "备注不能为空"
        }
    })
});